package org.wukl.vhr.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wukl.vhr.mapper.RoleMapper;
import org.wukl.vhr.model.Role;

import java.util.List;

@Service
public class RoleService {
    @Autowired
    RoleMapper roleMapper;
    public List<Role> getAllRoles()
    {
        return roleMapper.getAllRoles();
    }
    public Integer addRole(Role role)
    {
        if(!role.getName().startsWith("ROLE_"))
        {
            role.setName("ROLE_"+role.getName());
        }
        return roleMapper.insertSelective(role);
    }
    public Integer deleteRoleById(Integer rid)
    {
        return roleMapper.deleteByPrimaryKey(rid);
    }
}
